package com.testmanager.testmananger.quantitative.repository;

import com.querydsl.core.types.dsl.BooleanExpression;
import com.testmanager.testmananger.quantitative.constants.BugStatus;
import com.testmanager.testmananger.quantitative.domain.BugInfoEntity;
import com.testmanager.testmananger.quantitative.domain.QBugInfoEntity;
import com.testmanager.testmananger.quantitative.dto.BugSearchDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
@Transactional(readOnly = true)
public class BugInfoCustom {
    @Autowired
    BugInfoRepository bugInfoRepository;

    public List<BugInfoEntity> search(BugSearchDto bugSearchDto){
        QBugInfoEntity qBugInfoEntity = QBugInfoEntity.bugInfoEntity;
        BooleanExpression expression = qBugInfoEntity.id.isNotNull();
        if (bugSearchDto.getBugStatus() >= 0){
            expression = expression.and(qBugInfoEntity.status.eq(BugStatus.getValueOf(bugSearchDto.getBugStatus())));
        }
        if (null != bugSearchDto.getRepairerName() && "" != bugSearchDto.getRepairerName()){
            //expression = expression.and(qBugInfoEntity.)


        }
        return null;

    }
}
